<template>
  <el-input
    v-bind="item"
    :placeholder="item.placeholder || '请输入' + item.label"
    v-model="model[item.prop]"
    v-on="item.events || {}"
    :clearable="item.clearable === false ? false : true"
    @input="updataValue"
  >
    <slot :name="item.slot"></slot>
  </el-input>
</template>
<script setup>
const props = defineProps({
  item: Object,
  model: Object
})
const updataValue = (value) => {
  if (props.item.type === 'textarea' && props.item.maxlength) {
    props.model[props.item.prop] = value.substring(0, props.item.maxlength)
  }
}
</script>
